import { EditorState } from "./core/state";
import { EditorView } from "./core/view";
import { Schema, DOMParser } from "./core/model";
import { schema } from "./core/schema-basic";
import { addListNodes } from "./core/schema-list";
import { exampleSetup } from "./app";
import applyDevTools from "prosemirror-dev-tools"
import "./styles/editor.css";
import "./styles/index.css";

// Mix the nodes from prosemirror-schema-list into the basic schema to
// create a schema with list support.
const mySchema = new Schema({
    nodes: addListNodes(schema.spec.nodes, "paragraph block*", "block"),
    marks: schema.spec.marks,
});

// const mySchema = new Schema({
//     nodes: {
//         doc: { content: "paragraph+" },
//         paragraph: {
//             group: "block", content: "text*", parseDOM: [{ tag: "p" }], toDOM() {
//                 return ["p", 0]
//             },
//         },
//         blockquote: { group: "block", content: "block+" },
//         text: {

//         },

//     }
// })

const view = new EditorView(document.querySelector("#editor"), {
    state: EditorState.create({
        doc: DOMParser.fromSchema(mySchema).parse(
            document.querySelector("#content")
        ),
        plugins: exampleSetup({ schema: mySchema }),
    }),
});

window.view = applyDevTools(view);
